package algorithm.sort;

import java.util.Arrays;
import java.util.Collections;

public class bubbleSort {

    public static void sort(int[] arr) {
        for (int i = 1; i < arr.length; i++) {
            for (int j = arr.length-1; j >= i; j--) {
                if (arr[j] < arr[j-1]) {
                    int tmp = arr[j];
                    arr[j] = arr[j-1];
                    arr[j-1] = tmp;
                }
            }
            Arrays.stream(arr).forEach(x -> System.out.print(x+", "));
            System.out.println();
        }
    }

    public static void main(String[] args) {
        int[] arr = new int[]{2,3,51,6,7,2434,7,23,76,2,3};
        Arrays.stream(arr).forEach(x -> System.out.print(x+", "));
        System.out.println();
        sort(arr);
        Arrays.stream(arr).forEach(x -> System.out.print(x+", "));
    }

}
